package com.jxaummd.mushroom.core.base.activity;



import android.os.Bundle;
import android.support.annotation.Nullable;

import com.jxaummd.mushroom.R;
import com.jxaummd.mushroom.core.app.activity.ActivityManager;

import me.yokeyword.fragmentation.SupportActivity;
import me.yokeyword.fragmentation.SupportFragment;
import me.yokeyword.fragmentation.anim.DefaultHorizontalAnimator;
import me.yokeyword.fragmentation.anim.FragmentAnimator;


public abstract class ProxyActivity extends SupportActivity {


    public abstract  <T extends SupportFragment> T getRootFragment();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.core_activity_proxy);
        SupportFragment fragment= getRootFragment();
        if(findFragment(fragment.getClass())==null){
            loadRootFragment(R.id.core_framelayout_proxy,fragment);
        }
        ActivityManager.addObject(this);
    }


    @Override
    public FragmentAnimator onCreateFragmentAnimator() {
        return new DefaultHorizontalAnimator();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityManager.removeObject(this);
    }
}
